﻿using System;
using System.Net;
using Newtonsoft.Json;

namespace System.Net.DnsToolkit.Serializer.Json.Converter {

    public class IPAddressJsonConverter : JsonConverter {

        public override bool CanConvert(Type objectType) {
            return objectType == typeof(IPAddress);
        }

        public override object ReadJson(JsonReader reader, Type objectType, JsonSerializer serializer) {
            throw new NotImplementedException();
        }

        public override void WriteJson(JsonWriter w, object value, JsonSerializer serializer) {
            var ip = (IPAddress)value;
            w.WriteValue(ip.ToString());
        }
    }

}
